package poker;
/**
 * @author Taavet Tamm
 * @category poker app
 * @version %I% %G%
 * Class for poker card values and suits
 */
public class Card {
	private int value;
	private String suit;
	
	public Card(String suit, int value) {
		this.suit = suit;
		this.value = value;
	}
	
	public String toString() {
		String val;
		if (this.value == 14) val = "A";
		else if (this.value == 13) val = "K";
		else if (this.value == 12) val = "Q";
		else if (this.value == 11) val = "J";
		else val = Integer.toString(this.value);
		
		return this.suit+val;
	}
	/* Card to integer conversions:
	2c = 1 2d = 14 2h = 27 2s = 40
	3c = 2 3d = 15 3h = 28 3s = 41
	4c = 3 4d = 16 4h = 29 4s = 42
	5c = 4 5d = 17 5h = 30 5s = 43
	6c = 5 6d = 18 6h = 31 6s = 44
	7c = 6 7d = 19 7h = 32 7s = 45
	8c = 7 8d = 20 8h = 33 8s = 46
	9c = 8 9d = 21 9h = 34 9s = 47
	Tc = 9 Td = 22 Th = 35 Ts = 48
	Jc = 10 Jd = 23 Jh = 36 Js = 49
	Qc = 11 Qd = 24 Qh = 37 Qs = 50
	Kc = 12 Kd = 25 Kh = 38 Ks = 51
	Ac = 13 Ad = 26 Ah = 39 As = 52	
	public int toInt() {
		int card = -1;
		if      (this.suit == "c") card = this.value - 1;
		else if (this.suit == "d") card = this.value - 1 + 13;
		else if (this.suit == "h") card = this.value - 1 + 26;
		else if (this.suit == "s") card = this.value - 1 + 39;		
		return card;
	}*/
	/* Card to integer conversions:
	   2c =  1    2d =  2    2h =  3    2s =  4
	   3c =  5    3d =  6    3h =  7    3s =  8
	   4c =  9    4d = 10    4h = 11    4s = 12
	   5c = 13    5d = 14    5h = 15    5s = 16
	   6c = 17    6d = 18    6h = 19    6s = 20
	   7c = 21    7d = 22    7h = 23    7s = 24
	   8c = 25    8d = 26    8h = 27    8s = 28
	   9c = 29    9d = 30    9h = 31    9s = 32
	   Tc = 33    Td = 34    Th = 35    Ts = 36
	   Jc = 37    Jd = 38    Jh = 39    Js = 40
	   Qc = 41    Qd = 42    Qh = 43    Qs = 44
	   Kc = 45    Kd = 46    Kh = 47    Ks = 48
	   Ac = 49    Ad = 50    Ah = 51    As = 52	*/
	public int toInt() {
		int card = -1;
		if      (this.suit == "c") card = this.value - 1;
		else if (this.suit == "d") card = this.value - 1 + 13;
		else if (this.suit == "h") card = this.value - 1 + 26;
		else if (this.suit == "s") card = this.value - 1 + 39;		
		return card;
	}
}
